# -*- coding: utf-8 -*-
# @Time    : 2021/6/29 22:27
# @Author  : chron
# @FileName: locustfile.py
# @Software: PyCharm
# @E-mail  : chron@foxmil.com
# 线性 SequentialTaskSet
from locust import between, task
from locust.contrib.fasthttp import FastHttpUser
from json import loads


class send_locust(FastHttpUser):
    # host = "https://sp0.baidu.com"  # 域名
    host = "http://47.107.45.202:8888"

    wait_time = between(0.1, 0.8)  # 休息1-3秒

    def on_start(self):
        pass  # 前置

    def on_stop(self):
        pass  # 后置

    # @task
    # def send_http(self):
    #     with self.client.request("GET", "/8aQDcjqpAAV3otqbppnN2DJv/api.php?"
    #                              "query=13.111.14.21&resource_id=6006", name="查询ip接口") as response:
    #         assert loads(response.text).get("data")[
    #             0].get("location") == "美国佐治亚亚特兰大"

    @task
    def send_myos(self):
        with self.client.request("GET","/",name="测试") as f:
            print(f.text.encode("utf-8"))



